package com.yanfan.energy.domain.enums;

/**
 * @Author huan
 * @Description 生产管理-批次状态
 * @ClassName 2023年01月09日 14:27:00
 * @Version 1.0
 **/
public enum NumberUnitStatus {

    TEN_THOUSAND(1, "万"), TEN_MILLION(2, "千万"), BILLION(3, "亿"),
    ;


    private Integer code;

    private String desc;

    NumberUnitStatus(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    /**
     * 根据枚举type 返回String类型
     *
     * @param type
     * @return
     */
    public static String getStringByType(Integer type) {
        for (NumberUnitStatus item : NumberUnitStatus.values()) {
            if (item.getCode().equals(type)) {
                return item.getDesc();
            }
        }
        return "";
    }

    /**
     * 根据枚举  Value值返回type
     *
     * @param unit
     * @return
     */
    public static Integer getTypeByUnit(String unit) {
        if (unit == null || unit.isEmpty()) {
            return null;
        }
        for (NumberUnitStatus item : NumberUnitStatus.values()) {
            if (item.getDesc().equals(unit)) {
                return item.getCode();
            }
        }
        return null;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }


}
